import re
import requests
import openpyxl
url = 'https://kyfw.12306.cn/otn/resources/js/framework/station_name.js?station_version=1.9327'
herders = {
    'user-agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 Edg/130.0.0.0'
}
response = requests.get(url, headers=herders)
response.encoding = 'utf-8'
stations = re.findall("([\u4e00-\u9fa5]+)\|([A-Z]+)", response.text)
wb = openpyxl.Workbook()
ws = wb.active
for item in stations:
    ws.append(item)
wb.save('车站代码.xlsx')

print(stations)
